_BIN_NAME          = hookfuncMain
_BIN_SOURCE_PATH   = ./source/
_INCLUDE_PATH      = ./include/ \
                     $(addprefix -I,../library/include/)

_TARGET_PATH       = ./target/
_LIB_PATH          = ./library
_BIN_OBJECT_PATH   = $(_TARGET_PATH)obj/

CC                 = gcc -march=native
AR                 = ar
ECHO               = @echo
MKDIR              = mkdir -p
RM                 = rm -rf
CFLAGS             = -fPIC -Wall -O2

_LIB_DEF          += $(_LIB_PATH)/lib/libstudentsInfo.a

_BIN_SRC_C   = $(wildcard $(_BIN_SOURCE_PATH)*.c)
_BIN_OBJ     = $(addprefix $(_BIN_OBJECT_PATH),$(subst .c,.o,$(notdir $(_BIN_SRC_C))))


all:$(_TARGET_PATH)$(_BIN_NAME)
$(_TARGET_PATH)$(_BIN_NAME):$(_BIN_OBJ)
	@$(RM) -f $@
	$(CC) $(CFLAGS) -o $@ $^ $(_MACRO_DEF) $(_LIB_DEF)
	#@objdump -x $(_TARGET_PATH)$(_BIN_NAME) > $(_TARGET_PATH)symbol.txt
	@echo GO  "------------------>" $(_TARGET_PATH)$(_BIN_NAME)
	$(RM) $(_BIN_OBJECT_PATH)
	@echo GO  "------------------  !BEAUTIFUL!  ------------------"

$(_BIN_OBJECT_PATH)%.o:$(_BIN_SOURCE_PATH)%.c
	$(ECHO) CC $<
	@if [ ! -d $(_BIN_OBJECT_PATH) ]; then $(MKDIR) $(_BIN_OBJECT_PATH); fi
	$(CC) $(CFLAGS) -c $< -o $@ -I $(_INCLUDE_PATH)

.PHONY : clean

clean:
	$(RM) $(_BIN_OBJECT_PATH)